/*


	jQuery plugin: flashLoader
	Author: Ian Hart at Grand Union [ianh@thegrandunion.com]


	What?
	=====
	Find links to SWF files and embed them in the page.


	How?
	====
		- Links should point directly to a SWF file.
		- A link to adobe.com/go/getflashplayer is not required but is recommended.
		- Links should have a parent/ancestor with the CSS class "swf-movie-container" and an ID, e.g:
	
			<div>
				<div id="loader-movie" class="swf-movie-container">
					<p><a href="../media/flash/test.swf" class="swf-movie">Watch movie</a></p>
					<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
				</div>
			</div>
			
		- IMPORTANT! If the parent/ancestor doesn't have an ID, the SWF will not be embedded.
		- IMPORTANT! If you want to specify the SWF as 100% width and height, make sure you specify the CSS height of the parent of swf-movie-container.
		- Send the link elements through the jQuery object:
		
			$('a.swf-movie').flashLoader({
				'expressLocation' : '../../media/flash/expressInstall.swf'
			});


	Options
	=======
	swfWidth: The width of the SWF.
	swfHeight: The height of the SWF.
	flashVer: The lowest version of Flash Player required to view the SWF.
	expressLocation: The location of expressInstall.swf for users without Flash Player installed.
	
	
	Dependencies
	============
	- jQuery 1.3.2 or higher (jquery.com)
	- SWFObject v2.2 (code.google.com/p/swfobject)


*/
(function($){

	$.fn.flashLoader = function(settings){

		var G = {
			config : {
				swfWidth : '100%',
				swfHeight : '100%',
				flashVer : '9.0.0',
				expressLocation : 'expressInstall.swf'
			}
		};
		
		if(settings){ $.extend(G.config, settings); }


		function init(el){
		
			var parentID = '';

			el.each(function(i){
				parentID = $(this).parents('.swf-movie-container').attr('id');
				if(parentID !== ''){
					swfobject.embedSWF($(this).attr('href'), parentID, G.config.swfWidth, G.config.swfHeight, G.config.flashVer, G.config.expressLocation);
				}
			});
		
		}
		
		
		init(this);
		return this;
	
	};

})(jQuery);